# config.py
import os

# 路径配置
RAW_DATA_DIR = "/root/service/metro_traffic/origin_data"        # 原始数据目录
OUTPUT_DIR = "/root/service/metro_traffic/result_data"            # 输出目录
LOG_DIR = "log"                      # 日志目录

# 确保输出目录存在
os.makedirs(OUTPUT_DIR, exist_ok=True)
os.makedirs(LOG_DIR, exist_ok=True)

# 文件路径
PATH_REGION = os.path.join(RAW_DATA_DIR, "region_topology.csv")
PATH_TRAFFIC = os.path.join(RAW_DATA_DIR, "traffic_log.csv")
PATH_FAULT = os.path.join(RAW_DATA_DIR, "fault_event.csv")

# 输出路径
OUT_REGION = os.path.join(OUTPUT_DIR, "region_topology_clean", "region_topology_clean.csv")
OUT_TRAFFIC = os.path.join(OUTPUT_DIR, "traffic_log_clean", "traffic_log_clean.csv")
OUT_FAULT = os.path.join(OUTPUT_DIR, "fault_event_clean", "fault_event_clean.csv")
# merge_and_align.py 输出路径配置
OUTPUT_MERGED = os.path.join(OUTPUT_DIR, "merge_and_align", "traffic_topology_merged.csv")
OUTPUT_PATH_VALID = os.path.join(OUTPUT_DIR, "merge_and_align", "traffic_path_validation.csv")
OUTPUT_FAULT_ANALYSIS = os.path.join(OUTPUT_DIR, "merge_and_align", "fault_impact_analysis.csv")
# feaature_engineering.py 输入输出路径配置
FEATYRES_INPUT = os.path.join(RAW_DATA_DIR, "traffic_topology_merged.csv")
OUTPUT_FEATYRES = os.path.join(OUTPUT_DIR, "feature_engineering_stages", "traffic_features.csv")
# model_training.py 输入输出路径配置
MODEL_INPUT = os.path.join(RAW_DATA_DIR, "traffic_features.csv")
MODEL_OUTPUT = os.path.join(OUTPUT_DIR, "model_training", "traffic_forecast_lgbm.bin")
SCALER_OUTPUT = os.path.join(OUTPUT_DIR, "model_training", "scaler.pkl")
PREDICTION_OUTPUT = os.path.join(OUTPUT_DIR, "model_training", "predictions.csv")
# anomaly_detection.py 输入输出路径配置
ANOMALY_INPUT = os.path.join(RAW_DATA_DIR, "traffic_features.csv")
ANOMALY_OUTPUT = os.path.join(OUTPUT_DIR, "anomaly_detection", "anomalies.csv")
ISOLATION_MODEL = os.path.join(OUTPUT_DIR, "anomaly_detection", "isolation_forest.pkl")


# 合法枚举值
ALLOWED_PROTOCOLS = ['TCP', 'UDP', 'ICMP', 'HTTP', 'HTTPS', 'UNKNOWN']
ALLOWED_FAULT_TYPES = ["NODE_DOWN", "DDOS_ATTACK", 'NETWORK', 'HARDWARE', 'SOFTWARE', 'POWER', 'UNKNOWN']

# 数值范围限制
MAX_DURATION_MINUTES = 1440  # 最大故障持续时间（分钟）
MIN_TRAFFIC_BYTES = 1
MAX_TRAFFIC_BYTES = 1e9
MAX_LOAD_RATIO = 1.0

# 默认填充值
DEFAULT_REGION_FILL = "CN_GZ_000"
DEFAULT_PROTOCOL_FILL = "UNKNOWN"
DEFAULT_PARENT_REGION = "CN_GZ"

# 流程日志文件
CLEANING_PIPELINE_LOG = os.path.join(LOG_DIR, "data_cleaning_pipeline.log")
FEATURE_PIPELINE_LOG = os.path.join(LOG_DIR, "feature_engineering_pipeline.log")
DATA_CLEANING_LOG = os.path.join(LOG_DIR, "data_cleaning.log")